﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using NLog.Extensions.Logging;

namespace D.Util.UtilNLog
{
    /// <summary>
    /// 使用 NLog 日志框架，集成原生 ILogger 接口做日志记录；
    /// Microsoft.AspNetCore.Http.Abstractions
    /// Microsoft.Extensions.DependencyInjection.Abstractions
    /// NLog
    /// NLog.Extensions.Logging
    /// </summary>
    public static class NLogUtil
    {
        /// <summary>
        /// 添加日志中间件
        /// </summary>
        /// <param name="services"></param>
        public static void AddNLogUtil(this IServiceCollection services)
        {
            services.AddSingleton<INLogService, NLogService>();
            
            services.AddLogging(m =>
            {
                m.AddNLog();
            });
        } 
    }
}
